﻿using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Linq;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;

using Domain.Dummies.Dtos;
using Domain.Dummies.Dtos.Collections;

namespace KernelWorkflow.Activities
{
    public partial class SearchBookProxyActivity : SequenceActivity
    {
        public static readonly string SearchBookProxyActivityAccessObject = "SearchBook";

        public static DependencyProperty CurrentSessionProperty = DependencyProperty.Register("CurrentSession", typeof(SessionDto), typeof(SearchBookProxyActivity));
        public static DependencyProperty CurrentBookProperty = DependencyProperty.Register("CurrentBook", typeof(BookDto), typeof(SearchBookProxyActivity));
        //out
        public static DependencyProperty BookListProperty = DependencyProperty.Register("BookList", typeof(BooksBaseListDto), typeof(SearchBookProxyActivity));

        [Category("AUTHORIZATION_INPUT")]
        [Browsable(true)]
        public SessionDto CurrentSession
        {
            get
            {
                return ((SessionDto)(base.GetValue(SearchBookProxyActivity.CurrentSessionProperty)));
            }
            set
            {
                base.SetValue(SearchBookProxyActivity.CurrentSessionProperty, value);
            }
        }

        [Category("DATA_INPUT")]
        [Browsable(true)]
        public BookDto CurrentBook
        {
            get
            {
                return ((BookDto)(base.GetValue(SearchBookProxyActivity.CurrentBookProperty)));
            }
            set
            {
                base.SetValue(SearchBookProxyActivity.CurrentBookProperty, value);
            }
        }

        [Category("DATA_OUTPUT")]
        [Browsable(true)]
        public BooksBaseListDto BookList
        {
            get
            {
                return ((BooksBaseListDto)(base.GetValue(SearchBookProxyActivity.BookListProperty)));
            }
            set
            {
                base.SetValue(SearchBookProxyActivity.BookListProperty, value);
            }
        }

        private void SearchBookProxyCode_ExecuteCode(object sender, EventArgs e)
        {
            LibraryService.LibraryServiceClient libraryclient = new LibraryService.LibraryServiceClient();
            libraryclient.Open();

            BookList = libraryclient.GetBookRecord(CurrentSession, CurrentBook);

            libraryclient.Close();
        }

        public SearchBookProxyActivity()
        {
            InitializeComponent();
        }
    }
}
